<template>
  <div>
    <el-descriptions title="医院信息" border :column="3" style="margin: 15px">
      <el-descriptions-item label="医院名称">{{hospital.hosname}}</el-descriptions-item>
      <el-descriptions-item label="医院编号">{{hospital.hoscode}}</el-descriptions-item>
      <el-descriptions-item label="医院类型">{{hospital.hostype}}</el-descriptions-item>
      <el-descriptions-item label="医院logo">
        <img :src="'data:image/jpg;base64,'+hospital.logoData" style="width: 120px;height: 100px;">
      </el-descriptions-item>
      <el-descriptions-item label="地址" :span="2">{{hospital.address}}</el-descriptions-item>
      <el-descriptions-item label="坐车地址" :span="3">{{hospital.route}}</el-descriptions-item>
      <el-descriptions-item label="医院简介" :span="3">{{hospital.intro}}</el-descriptions-item>
    </el-descriptions>

    <el-descriptions title="预约规则" border :column="3" style="margin: 15px">
      <el-descriptions-item label="预约周期">{{hospital.bookingRule.cycle}}</el-descriptions-item>
      <el-descriptions-item label="放号时间">{{hospital.bookingRule.releaseTime}}</el-descriptions-item>
      <el-descriptions-item label="停挂时间">{{hospital.bookingRule.stopTime}}</el-descriptions-item>
      <el-descriptions-item label="退号截止天数">{{hospital.bookingRule.quitDay == 0?'预约当天':'预约前一天'}}</el-descriptions-item>
      <el-descriptions-item label="取号地点">{{hospital.bookingRule.fetchAddress}}</el-descriptions-item>
    </el-descriptions>
    <router-link :to="'/hospSet/hospitalList'">
      <el-button type="success">返回列表</el-button>
    </router-link>
  </div>
</template>

<script>
import apiObj from '../../api/hospital/showDetails'

export default {
  data () {
    return {
      hospital: {},
    }
  },
  methods: {
    showHospital (id) {
      // 取出条件
      apiObj.showDetails(id).then(({ data }) => {
        if (data.code == 200) {
          this.hospital = data.data
        } else {
          this.$message({
            message: '未查询到信息，可能服务器出小差了',
            type: 'warning'
          })
        }
      }).catch(e => {
        this.$message.error("查询出错啦，请稍后再试!")
      })
    }
  },
  created () {
    // 获取条件
    const id = this.$route.params.id
    this.showHospital(id)
  }
}
</script>
